package com.lzw.cpvideoplayer.ulit;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.widget.ImageView;

import androidx.core.graphics.drawable.RoundedBitmapDrawable;
import androidx.core.graphics.drawable.RoundedBitmapDrawableFactory;

public class Ulit {

    //https://api.pingcc.cn/video/search/{option}/{key}/{from}/{size}
    //option；选择搜索项 标题：title ， 导演 ：director，主演：actor，地区：region，上映：releaseTime，分类：videoType
    //key 搜索关键字
    //from 当前页数，留空默认1
    //size 一页显示的数量，留空默认10，最多30
    public static String SEARCH_URL = "https://api.pingcc.cn/video/search/title/";//搜索页

    //https://api.pingcc.cn/videoChapter/search/{videoId}
    public static String CHAPTER_URL = "https://api.pingcc.cn/videoChapter/search/";//视频播放页

    public static String VideoType_URL = "https://api.pingcc.cn/video/search/videoType/动漫";
    /**
     * 设置图片为圆形
     * @param image ImageView
     */
    public static void toRoundBitmap(Context context, ImageView image, int UserImage){

        Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(),UserImage);
        RoundedBitmapDrawable roundImage = RoundedBitmapDrawableFactory.create(context.getResources(),bitmap);
        roundImage.setAntiAlias(true);
        roundImage.setCornerRadius(bitmap.getWidth()/2);
        image.setImageDrawable(roundImage);
    }

    /**
     * 获取页数
     */
    public static int getCountMax(int count){
        if(count%10==0){
            return count/10;
        }else {
            return count/10+1;
        }

    }
}
